package com.gui.hosp.controller;

import com.gui.common.result.Result;
import com.gui.hosp.service.HospitalService;
import com.gui.model.hosp.Hospital;
import com.gui.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import sun.plugin2.main.server.ResultID;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author GodLamp
 * @date 2022/10/22 11:46
 */
@Api(tags = "医院管理接口")
@RestController
@RequestMapping(path = "/admin/hosp/hospital")
public class HospitalController {
    @Resource
    private HospitalService hospitalService;

    /**
     * 医院列表--条件查询分页
     * @param page
     * @param limit
     * @return
     */
    @ApiOperation(value = "获取分页列表")
    @GetMapping(path = "list/{page}/{limit}")
    public Result listHospital(@ApiParam(name = "page", value = "当前页码", required = true) @PathVariable(name = "page") Integer page,
                               @ApiParam(name = "limit", value = "每页记录数", required = true) @PathVariable(name = "limit") Integer limit,
                               @ApiParam(name = "hospitalQueryVo", value = "查询对象", required = false) HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pages = hospitalService.selectHospPage(page, limit, hospitalQueryVo);

        return Result.ok(pages);
    }

    @ApiOperation(value = "更新医院上线状态")
    @PutMapping(path = "updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable(name = "id") String id,
                                   @PathVariable(name = "status") Integer status){
        hospitalService.update(id, status);
        return Result.ok();
    }
    
    @ApiOperation(value = "医院详情信息")
    @GetMapping(path = "showHospDetail/{id}")
    public Result getHospById(@PathVariable(name = "id") String id){
        Map<String, Object> maps = hospitalService.getHospbyId(id);

        return Result.ok(maps);
    }
}
